package kr.co.doriclassic.lab06;

import java.util.Scanner;

public class Pi {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int loop_cnt;
		double numerator=4.0; 
		double denominator=1.0;
		double sum=0.0;
		
		System.out.print("반복횟수:");
		loop_cnt = sc.nextInt();
		
		while(loop_cnt>0){
			sum=sum+numerator/denominator;
			numerator=-1.0*numerator;
			denominator=denominator+2.0;
			--loop_cnt;
		}
		System.out.printf("Pi = %f",sum);

	}
}
